<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci = & get_instance(); 
	$id = $this->input->post('id',0);
	$positionDataArray = array('home'=> 'Home', 'right'=> 'Right');	
?>
<?php if(!$id): ?>
<form action="<?php echo site_url('admin/dataman/advertising/add_edit_submit');?>" name="add_edit_submit" id="add_edit_submit" method="post" enctype="multipart/form-data" >
	
	<div class="grid2"><span class="bold">Link:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="url" name="url" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="url_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">Order:</span></div>
	<div class="grid6"><input type="text" maxlength="5" id="ordering" name="ordering" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="ordering_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">Image:</span></div>
	<div class="grid4"><?php echo form_upload('image');?></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">Position:</span></div>
	<div class="grid6"><?php echo form_dropdown( 'position',
								$options = $positionDataArray,
								$selected = array(),
								"id='position'"
							);	?></div>	
	<div class="clrboth"></div>
	
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="clrboth"></div>	
	
</form>
<?php else:?>
<form action="<?php echo site_url('admin/dataman/advertising/add_edit_submit');?>" name="add_edit_submit" id="add_edit_submit" method="post" enctype="multipart/form-data" >
	<?php 
		$ADV = $ci->advertising_entity->init('id',$id);
	?>
	
	<div class="grid2"><span class="bold">Link:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="url" name="url" value="<?php echo $ADV->getUrl();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="url_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">Order:</span></div>
	<div class="grid6"><input type="text" maxlength="5" id="ordering" name="ordering" value="<?php echo $ADV->getOrdering();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="ordering_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">Image:</span></div>
	<div class="grid4"><?php echo form_upload('image');?></div>
	<div class="grid4"><?php echo thumb($ADV->getAdvImage(),50,30);?></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">Position:</span></div>
	<div class="grid6"><?php echo form_dropdown( 'position',
								$options = $positionDataArray,
								$selected = array($ADV->getPosition()),
								"id='position'"
							);	?></div>	
	<div class="clrboth"></div>
	
	<input type="hidden" name="id" id="id" value="<?php echo $ADV->getId();?>" />
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="clrboth"></div>	
	
</form>
<?php endif;?>